"""
# File       : middlewaretest.py
# Time       ：2024/6/7 12:39
# Author     ：史桃桃
# version    ：python 3.8
# Description：
"""
from django.contrib import auth
from django.contrib.auth.models import AnonymousUser
from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin
from django.http.response import HttpResponse


class LoginTest(MiddlewareMixin):
    def process_request(self, request):
        white_path = ['/captcha_study/register/', '/captcha_study/logout/', '/captcha_study/login/',
                      '/captcha_study/captcha_img/'
                      ]
        path = request.path_info
        if (path not in white_path) and not(request.user.is_authenticated):
            return redirect('captcha_demo_app:login')



